package com.fengmi.goods.controller;


import com.fengmi.comm.ResultVO;
import com.fengmi.goods.MallGoods;
import com.fengmi.goods.service.IMallGoodsService;
import com.fengmi.goods.service.impl.MallGoodsServiceImpl;
import com.fengmi.goods.vo.MallGoodsAndCatVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sujie
 * @since 2022-11-22
 */
@RestController
@RequestMapping("/goods/mall-goods")
@RefreshScope   //动态刷新
public class MallGoodsController {
    @Value("${goods.topn}")
    private Integer topn;
    @Autowired
    IMallGoodsService mallGoodsService;

    @RequestMapping("getAllGoodsAndCat")
    public List<MallGoodsAndCatVO> getAllGoodsAndCat() {
        return  mallGoodsService.getAllGoodsAndCat(this.topn);
    }

    @RequestMapping("getAllGoods")
    public List<MallGoods> getAllGoods() {
        return  mallGoodsService.getAllGoods();
    }

    @RequestMapping("goodsAudit/{spuId}")
    public ResultVO goodsAudit(@PathVariable Long spuId) {
        return  mallGoodsService.goodsAudit(spuId);
    }
    @RequestMapping("getGoodsAndSku/{spuId}")
    public MallGoods getGoodsAndSku(@PathVariable  Long spuId){  //查询商品及sku信息
        return  mallGoodsService.getGoodsAndSku(spuId);
    }
}
